#include<iostream>
#include "lldi.h"
using std::cout;

template<class T>ListaDubla<T>::ListaDubla(){
  this->p=NULL;
}
template<class T>ListaDubla<T>::~ListaDubla(){
	delete p;
}      
template<class T>void ListaDubla<T>::add(T info){
  Nod<T>* nou=new Nod<T>();
  nou->info=info;
  nou->urm=NULL;
	nou->ant=NULL;
  Nod<T>*r=this->p;
  if(r!=NULL)
  {
   while(r->urm!=NULL)
  	r=r->urm;
	  r->urm=nou;
		nou->ant=r;
  }
  else
   this->p=nou;    
}
template<class T>void ListaDubla<T>::print()const{
  Nod<T>*r;
  r=this->p;
	while(r!=NULL)
	{
   cout<<"\n"<<r->info;
	 r=r->urm;
	}
}
template<class T>int ListaDubla<T>::dim()const{
  Nod<T>*r;
  r=this->p;
	int x=0;
	while(r!=NULL)
	{
	  r=r->urm;
	 	x++;
	}
	return x;
}
template<class T>void ListaDubla<T>::suprimare(T k){
  Nod<T>*r=this->p;
	Nod<T>*temp;
	int b;	
 	b=0;
	 r=this->p;
	 while(b==0 && r!=NULL)
		 if(r->info==k)  b=1;
			 else r=r->urm;	
	 Nod<T>*pred,*suc;
	 pred=r->ant;
	 suc=r->urm;
	 if(r->urm!=NULL)suc->ant=pred;
	 if(r->ant!=NULL)pred->urm=suc;
	 if(r==this->p)this->p=p->urm;
	 delete r;
}
